﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TargetTrigger : MonoBehaviour
{
    public FirstController sceneController;
    public ScoreRecorder scoreRecorder;

    void Start()
    {
        sceneController = SSDirector.getInstance().currentSceneController as FirstController;
        scoreRecorder = Singleton<ScoreRecorder>.Instance;
    }

    void OnTriggerEnter(Collider arrowHead)
    {
        Transform arrow = arrowHead.gameObject.transform.parent;
        if (arrow == null)
        {
            return;
        }
        if (arrow.tag == "arrow")
        {
            arrow.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 0);
            arrow.GetComponent<Rigidbody>().isKinematic = true;
            arrowHead.gameObject.SetActive(false);
            arrow.tag = "hit";

            int score = this.gameObject.gameObject.GetComponent<TargetData>().GetScore();
            scoreRecorder.Record(score);
        }
    }
}
